#include "skin.h"
#include <cassert>
#include "font.h"
#include "scrollskin.h"
#include "knobskin.h"
#include "buttonskin.h"

Skin::Skin()
: m_pFont(NULL), m_pScrollSkin(NULL), m_pKnobSkin(NULL) {
     // initialize colors vector
     for (size_t i=0; i<Skin::ColorCount; i++)
	  m_colors.push_back(al_map_rgb(0,0,0));
     // initialize button skins vector
     for (size_t i=0; i<Skin::ButtonCount; i++)
	  m_buttonSkins.push_back(NULL);
}

Skin::~Skin() {
     if (m_pFont)
	  delete m_pFont;
     if (m_pScrollSkin)
	  delete m_pScrollSkin;
     if (m_pKnobSkin)
	  delete m_pKnobSkin;
     for (unsigned int i=0; i<m_buttonSkins.size(); i++) {
	  if (m_buttonSkins[i])
	       delete m_buttonSkins[i];
     }
}

Font* Skin::font() const {
     return m_pFont;
}

void Skin::setFont(Font *font) {
     m_pFont = font;
}

ScrollSkin* Skin::scrollSkin() const {
     return m_pScrollSkin;
}

void Skin::setScrollSkin(ScrollSkin *scrollSkin) {
     m_pScrollSkin = scrollSkin;
}

KnobSkin* Skin::knobSkin() const {
     return m_pKnobSkin;
}

void Skin::setKnobSkin(KnobSkin *knobSkin) {
     m_pKnobSkin = knobSkin;
}

const ALLEGRO_COLOR& Skin::color(Skin::Colors color) const {
     assert(color != Skin::ColorCount);
     return m_colors[color];
}

void Skin::setColor(Skin::Colors color, const ALLEGRO_COLOR &val) {
     assert(color != Skin::ColorCount);
     m_colors[color] = val;
}

ButtonSkin* Skin::buttonSkin(Skin::Buttons button) const {
     assert(button != Skin::ButtonCount);
     return m_buttonSkins[button];
}

void Skin::setButtonSkin(Skin::Buttons button, ButtonSkin *pSkin) {
     assert(button != Skin::ButtonCount);
     m_buttonSkins[button] = pSkin;
}
